const { NacosNamingClient } = require('nacos');

const client = new NacosNamingClient({
    logger: console,
    serverList: 'localhost:8848',
    namespace: 'public',
});

(async function() {
    await client.ready();

    // registry instance
    await client.registerInstance('supreme-express-server', {
        ip: 'localhost',
        port: 3000,
    });
})();

// subscribe instance
client.subscribe('supreme-express-server', hosts => {
    console.log(hosts);
});

module.exports = client;